#include "netstatitemmodel.h"
#include "QDebug"

NetStatItemModel::NetStatItemModel ( QString &_nsNetstat,
                                QString &_nsPic,
                                QString &_nsSDesc,
                                QString &_nsLDesc,
                                QString &_procPath,
                                QString &_procName,
                                QString &_nsPid,
                                QString &_nsLAddr,
                                QString &_nsLPort,
                                QString &_nsFAddr,
                                QString &_nsFPort,
                                QObject *parent ) : ListItem(parent),
    ns_netstat(_nsNetstat), ns_pic(_nsPic), ns_sdescr(_nsSDesc), ns_ldescr(_nsLDesc),
    ns_procpath(_procPath), ns_procname(_procName), ns_pid(_nsPid),
    ns_laddr(_nsLAddr), ns_lport(_nsLPort), ns_faddr(_nsFAddr), ns_fport(_nsFPort)
{}

NetStatItemModel::~NetStatItemModel() {
    //qDebug() << "NetStatItemModel::~NetStatItemModel()";
}

QVariant NetStatItemModel::data(int role) const
{
  switch(role) {
  case NetstatStat:
    return nsStat();
  case NetstatPic:
    return nsPic();
  case NetstatSDescr:
    return nsSDescr();
  case NetstatProcPath:
    return nsProcPath();
  case NetstatProcName:
    return nsProcName();
  case NetstatPID:
    return nsPid();
  case NetstatLAddr:
    return nsLAddr();
  case NetstatLPort:
    return nsLPort();
  case NetstatFAddr:
    return nsFAddr();
  case NetstatFPort:
    return nsFPort();
  case NetstatLDescr:
    return nsLDescr();
  default:
    return QVariant();
  }
}

QHash<int, QByteArray> NetStatItemModel::roleNames() const
{
  QHash<int, QByteArray> names;
  names[NetstatStat] = "nsState";
  names[NetstatPic] = "nsPicture";
  names[NetstatSDescr] = "nsSDescr";
  names[NetstatLDescr] = "nsLDescr";
  names[NetstatProcPath] = "nsProcPath";
  names[NetstatProcName] = "nsProcName";
  names[NetstatPID] = "nsPid";
  names[NetstatLAddr] = "nsLAddr";
  names[NetstatLPort] = "nsLPort";
  names[NetstatFAddr] = "nsFAddr";
  names[NetstatFPort] = "nsFPort";
  return names;
}
